package cn.cs.mathgo.sso.controller;

import cn.cs.mathgo.common.AjaxJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

/**
 * 登录地址
 */
@RestController
public class LoginController {
    @Autowired
    @GetMapping("authentication/require")
    public ModelAndView require() {
        return new ModelAndView("ftl/login");
    }
    @GetMapping("/user")
    public Object user(Authentication authentication) {
        return AjaxJson.success().setObj(authentication.getPrincipal());
    }

 /*   @GetMapping("/testFeign")
    public Object getList(){
        return AjaxJson.success().setObj(userFeignClient.getByName("admin"));
    }*/
    @GetMapping("/me")
    public Object me(Authentication authentication) {
        return AjaxJson.success().setObj(authentication);
    }
}
